
package org.onion.pattern.domain.annotation;

import java.lang.annotation.*;

/**
 * Identifies a bounded context. A description of a boundary (typically a subsystem, or the work of a particular team)
 * within which a particular model is defined and applicable. A bounded context has an architectural style and contains
 * domain logic and technical logic.
 *
 * @see <a href="https://domainlanguage.com/wp-content/uploads/2016/05/DDD_Reference_2015-03.pdf">Domain-Driven Design
 *      Reference (Evans) - Bounded Contexts</a>
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.PACKAGE, ElementType.ANNOTATION_TYPE })
@Documented
public @interface BoundedContext {

	/**
	 * A stable identifier for the bounded context. If not defined, an identifier will be derived from the annotated
	 * element, usually a package. That allows tooling to derive name and description by applying some kind of convention
	 * to the identifier.
	 * <p>
	 * Assuming a package {@code com.acme.myapp} annotated with {@code BoundedContext}, tooling could use a resource
	 * bundle to lookup the keys {@code com.acme.myapp._name} and {@code com.acme.myapp._description} to resolve name and
	 * description respectively.
	 *
	 * @return
	 */
	String id() default "";

	/**
	 * A human readable name for the bounded context. Might be overridden by an external resolution mechanism via
	 * {@link #id()}. Tooling should prevent both {@link #value()} and {@link #name()} from being configured at the same
	 * time. If in doubt, the value defined in {@link #name()} will be preferred.
	 *
	 * @return
	 * @see #id()
	 */
	String name() default "";

	/**
	 * An alias for {@link #name()}. Tooling should prevent both {@link #value()} and {@link #name()} from being
	 * configured at the same time. If in doubt, the value defined in {@link #name()} will be preferred.
	 *
	 * @return
	 * @see #name()
	 */
	String value() default "";

	/**
	 * A human readable description for the bounded context. Might be overridden by an external resolution mechanism via
	 * {@link #id()}.
	 *
	 * @return
	 * @see #id()
	 */
	String description() default "";
}
